<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 1. 用户输入一个整数n：
        // 求1! + 2! + 3! + 4! + …… + n!的和
        // 叹号表示阶乘，如4! = 1 * 2 * 3 * 4
        let n = parseInt(prompt("请输入一个整数: "));
        function jiecheng(a) {
            let res = 1;
            for (let i = 2 ; i <= a ; i++) {
              res = res * i;
            }
            return res;
        }

        let sum = 0;
        for (let i = 1 ; i <= n ; i++) {
            sum = sum + jiecheng(i);
        }
        console.log('最终的结果为：' + sum);
       

    </script>
</head>

<body>

</body>

</html>